/**
 * Created by huangchao on 22/12/2017.
 */
/**
 * Created by huangchao on 20/12/2017.
 * @param {string} title - this is title description.
 * @param {function} ok - 确定的回调.
 * @param {function} cancla - 取消的回调
 * @param {boolen} disabled - 是否可编辑
 * @param {boolen} visible - 是否可见
 * @param {array} ids - 数组id
 */

import React, { Component } from 'react'
import { Modal, Radio, Mention } from 'antd'
import style from './style.less'
const RadioGroup = Radio.Group
const { toString } = Mention

class Audit extends Component {

  state = {
    value: 2,
  }

  selectRadio = (e) => {
    this.setState({
      value: e.target.value,
    })
  }

  mentionReason = editorState => {
    this.feedback = toString(editorState)
  }

  callBack = () => {
    const value = {
      customerList: this.props.ids,
      status: this.state.value,
      remark: this.feedback,
    }
    if(!this.props.disabled) {
      this.props.ok(value)
    } else {
      this.props.cancle()
    }
  }

  render() {
    return(
      <Modal
        maskClosable={false}
        title={this.props.title || '线索审核'}
        style={{ top: 160 }}
        visible={this.props.visible}
        onCancel={this.props.cancle}
        onOk={this.callBack}
        className={style.Modal}
      >
        <div className={style.number}>
          <span className={style.auditSpan}>线索编号：</span>
          <span>{(this.props.ids || []).join(',')}</span>
        </div>
        <div>
          <span className={style.auditSpan}>线索审核：</span>
          <RadioGroup disabled={this.props.disabled} onChange={this.selectRadio} value={this.state.value}>
            <Radio value={2}>审核通过</Radio>
            <Radio value={3}>审核不通过</Radio>
          </RadioGroup>
        </div>
        <div className={style.reason}>
          <span className={style.auditSpan}>反馈详情：</span>
          <Mention
            disabled={this.props.disabled}
            style={{ width: '100%', height: 100 }}
            onChange={this.mentionReason}
            multiLines
          />
        </div>
      </Modal>
    )
  }
}

export default Audit
